# -*- coding: utf-8 -*-
import threading

"""
支持自定义初始化参数
这个实现允许在创建单例对象时传入自定义的初始化参数。
"""


class Singleton(object):
    _instance = None
    _lock = threading.Lock()

    def __new__(cls, *args, **kwargs):
        with cls._lock:
            if cls._instance is None:
                cls._instance = super(Singleton, cls).__new__(cls)
                cls._instance.__init__(*args, **kwargs)
        return cls._instance

    def __init__(self, param1, param2):
        self.param1 = param1
        self.param2 = param2
